import { fillRect, fillText } from "@/utils/common"
export default class Rect {
  constructor(key, height, value, color, x, y, width = 30) {
    this.width = width
    this.height = height
    this.value = value
    this.color = color
    this.x = x
    this.y = y
    this.key = key
  }

  draw(ctx) {
    ctx.beginPath()
    ctx.fillStyle = this.color
    fillRect(ctx, this.x, this.y, this.width, this.height)
    ctx.fillStyle = 'black'
    fillText(ctx, this.value, this.x + this.width / 2, this.y + this.height - 10)
  }

  deepCopy() {
    return new Rect(this.key, this.height, this.value, this.color, this.x, this.y, this.width)
  }
}